package com.fy56.platform.goodsTracking.api.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fy56.platform.goodsTracking.api.UploadApi;
import com.fy56.platform.goodsTracking.commons.DateUtil;
import com.fy56.platform.goodsTracking.commons.unit.SystemConstants;
import com.fy56.platform.goodsTracking.model.*;
import com.fy56.platform.goodsTracking.service.GoodstrackedRecordPublicServie;
import com.fy56.platform.goodsTracking.service.GoodstrackedRecordTopPublicService;
import com.fy56.platform.goodsTracking.service.JrptService;
import com.fy56.platform.goodsTracking.service.TenantService;
import com.fy56.platform.goodsTracking.web.*;
import com.google.common.collect.Maps;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * Created by XTK on 2016-11-23.
 */
@Repository
public class UploadApiImpl implements UploadApi {
    @Autowired
    private GoodstrackedRecordTopPublicService topService;
    @Autowired
    private GoodstrackedRecordPublicServie subService;
    static Logger log = Logger.getLogger(UploadApiImpl.class);
    @Autowired
    JrptExecutor jrptExecutor;
    @Autowired
    JrptService jrptService;
    @Autowired
    private TenantService tenantService;

    @Override
    public String doLogin(Jrpt jrpt) {
        //初始化接口
        String jrptResult = jrptExecutor.login(jrpt);
        JSONObject jsonObject = JSON.parseObject(jrptResult);
        String token = jsonObject.get("tokenID").toString();
        JSONObject resultObject = JSON.parseObject(JSON.toJSONString(jsonObject.get("result")));
        String codeNum = resultObject.get("codeNum").toString();
        //  String codeMessage = resultObject.get("codeMessage").toString();
        Jrpt jrpt_new = new Jrpt();
        jrpt_new.setId(jrpt.getId());
        jrpt_new.setMessage(jrptResult);
        jrptService.update(jrpt_new);
        if (!codeNum.equals("1000")) {
            return "";
        } else {
            return token;
        }
    }

    @Override
    public void doUpload_Main(Jrpt jrpt, UserToken userToken, String endTime) {

        //查询未上传货物跟踪主
        List<GoodstrackedRecordTopPublic> tops = topService.selectByNotUpload(jrpt.getOrganizationcode(), jrpt.getLosttime(), endTime);
        log.info(jrpt.getOrganizationcode() + ":需要上传主数据:" + tops.size());
        if (tops.size() == 0) return;

//上传货物跟踪主
        for (GoodstrackedRecordTopPublic top : tops) {
            String result = jrptExecutor.upload_Top(top, userToken, jrpt);
            log.info(top.getConsignmentbillmasterid()+":"+result);

        /*    GoodstrackedRecordTopPublic topPublic = new GoodstrackedRecordTopPublic();
            if (code.equals("1000") || code.equals("3012")) {
                //成功
                topPublic.setId(top.getId());
                topPublic.setUpload("1");
                topPublic.setUploaderror("");
            } else {
                //成功
                topPublic.setId(top.getId());
                topPublic.setUpload("2");
                topPublic.setUploaderror(message);
            }*/
            //保存结果
            //topService.updateByupload(topPublic);
        }


    }

    @Override
    public void doUpload_Sub(Jrpt jrpt, UserToken userToken, String endTime) {


        //查询未上传货物跟踪主
        List<GoodstrackedRecordPublic> subs = subService.selectByNotUpload(jrpt.getOrganizationcode(), jrpt.getLosttime(), endTime);
        log.info(jrpt.getOrganizationcode() + ":需要上传明细数据:" + subs.size());
        if (subs.size() == 0) return;

        for (GoodstrackedRecordPublic sub : subs) {
            String result = jrptExecutor.upload_Sub(sub, jrpt);
            log.info(JSON.toJSONString(sub)+":"+result);
     /*       String code = "", message = "";
            try {
                JSONObject json = JSON.parseObject(result);
                code = json.get("codeNum").toString();
                message = json.get("codeMessage").toString();
            } catch (Exception e) {
                message = result;
            }
            GoodstrackedRecordPublic subPublic = new GoodstrackedRecordPublic();
            if (code.equals("1000") || code.equals("3012")) {
                //成功
                subPublic.setRecordid(sub.getRecordid());
                subPublic.setUpload("1");
                subPublic.setUploaderror("");
            } else {
                //成功
                subPublic.setRecordid(sub.getRecordid());
                subPublic.setUpload("2");
                subPublic.setUploaderror(message);
            }*/
            //保存结果
            //subService.updateByupload(subPublic);
        }
        //更新最后上传日期
        jrpt.setLosttime(endTime);
        jrptService.updateLast(jrpt);
    }

    @Override
    public void doUpload_Goods_Top(String beginDate,String endDate) {
        int pointsDataLimit = 300;//限制条数
        //查询未上传货物跟踪主
        SimpleDateFormat sFormat = new SimpleDateFormat("yyyy-MM-dd");
        String begin = sFormat.format(new Date())+" 00:00:00";
        String end   = sFormat.format(new Date())+" 23:59:59";
        if(beginDate!=null&&beginDate.length()!=0){
            begin = beginDate+" 00:00:00";
        }
        if (endDate!=null&&endDate.length()!=0){
            end   = endDate+" 23:59:59";
        }
        try{
            Long beforeGOODS = System.currentTimeMillis();//货物跟踪推送开始时间
            Long afterGOODS = System.currentTimeMillis();//货物跟踪推送结束时间

            List<GoodstrackedRecordTopPublicF6> subs =topService.selectNotList("", begin, end);
            log.info("订单总数:" + subs.size());
            beforeGOODS = System.currentTimeMillis();

            if(subs!=null&&subs.size()>0){

                Integer size = subs.size();
                if(pointsDataLimit<size){
                    int part = size/pointsDataLimit;//分批数
                    ExecutorService pool = Executors.newFixedThreadPool(part+1);

                    for (int c = 0; c < part; c++) {
                        List<GoodstrackedRecordTopPublicF6> listPage = subs.subList(0, pointsDataLimit);
                        try{
                            JSONArray a = (JSONArray) JSONObject.toJSON(listPage);
                            GoodsCallable callable = new GoodsCallable( "top",a.toString());
                            Future fContent = pool.submit(callable);
                        }catch (Exception e){
                            log.error("线程异常",e);

                        }
                        //剔除
                        subs.subList(0, pointsDataLimit).clear();
                    }
                    pool.shutdown();
                    if(!subs.isEmpty()){
                        try{
                            for (GoodstrackedRecordTopPublicF6 sub : subs) {
                                jrptExecutor.uploadGoodsTrace(SystemConstants.GOODS_URL,"",sub);
                            }
                        }catch (Exception e){
                            log.error("线程异常2",e);
                        }
                    }
                }else{
                    for (GoodstrackedRecordTopPublicF6 sub : subs) {
                        jrptExecutor.uploadGoodsTrace(SystemConstants.GOODS_URL,"",sub);
                    }
                }
            }
            afterGOODS = System.currentTimeMillis();
            System.out.println("上传订单信息用时：" + (afterGOODS - beforeGOODS) + "毫秒。");
        }catch (Exception e){
            //topService.selectNotList  subService.selNotUploadList
            log.info("上传订单信息异常 error:" ,e);
        }

        try {
            Long beforeGOODS = System.currentTimeMillis();//货物跟踪推送开始时间
            Long afterGOODS = System.currentTimeMillis();//货物跟踪推送结束时间
            List<GoodsPublic> goods = subService.selectByNotUpload_List("", begin, end);
            Map<String, Object> ceshi = Maps.newHashMap();
            ceshi.put("cccccc",goods);
            List<GoodsPublic> ceshic =(List<GoodsPublic> )ceshi.get("cccccc");
            log.info("路由总数:" + goods.size());
            beforeGOODS = System.currentTimeMillis();
            if (goods!=null&& goods.size()>0){

                Integer size = goods.size();
                if(pointsDataLimit<size){

                    int part = size/pointsDataLimit;//分批数
                    ExecutorService pool = Executors.newFixedThreadPool(part+1);
                    for (int c = 0; c < part; c++) {

                        List<GoodsPublic> listPage = goods.subList(0, pointsDataLimit);
                        try{
                            JSONArray a = (JSONArray) JSONObject.toJSON(listPage);
                            GoodsCallable callable = new GoodsCallable( "1",a.toString());
                            Future fContent = pool.submit(callable);
                        }catch (Exception e){
                            log.error("线程异常3",e);

                        }
                        //剔除
                        goods.subList(0, pointsDataLimit).clear();
                    }
                    if(!goods.isEmpty()){
                        try{
                            JSONArray a = (JSONArray) JSONObject.toJSON(goods);
                            GoodsCallable callable = new GoodsCallable( "1",a.toString());
                            Future fContent = pool.submit(callable);
                        }catch (Exception e){
                            log.error("线程异常4",e);

                        }
                    }
                    pool.shutdown();
                }else{
                    try{
                        ExecutorService pool = Executors.newFixedThreadPool(1);
                        JSONArray a = (JSONArray) JSONObject.toJSON(goods);
                        GoodsCallable callable = new GoodsCallable( "1",a.toString());
                        Future fContent = pool.submit(callable);
                        pool.shutdown();
//                         for (GoodsPublic good:goods){
//                            jrptExecutor.uploadSubTracking(SystemConstants.GOODS_URL,good);
//                         }
                    }catch (Exception e){
                        log.error("线程异常4",e);

                    }

                }
            }
            afterGOODS = System.currentTimeMillis();
            SimpleDateFormat sFormata = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String begina = sFormata.format(new Date());
            System.out.println("上传订单路由用时：" + (afterGOODS - beforeGOODS) + "毫秒。"+begina);
        }catch (Exception e){
            log.info("上传路由信息异常 error:",e );
        }
    }


    @Override
    public void doPostGoods(String beginDate,String endDate) {
        int pointsDataLimit = 10000;//限制条数
        //查询未上传货物跟踪主
        SimpleDateFormat sFormat = new SimpleDateFormat("yyyy-MM-dd");
        String begin = sFormat.format(new Date())+" 00:00:00";
        String end   = sFormat.format(new Date())+" 23:59:59";
        if(beginDate!=null&&beginDate.length()!=0){
            begin = beginDate+" 00:00:00";
        }
        if (endDate!=null&&endDate.length()!=0){
            end   = endDate+" 23:59:59";
        }
        try{
            Long beforeGOODS = System.currentTimeMillis();//货物跟踪推送开始时间
            Long afterGOODS = System.currentTimeMillis();//货物跟踪推送结束时间
            List<GoodstrackedRecordTopPublicF6> subs =topService.selectNotList("", begin, end);
            log.info("订单总数:" + subs.size());
            beforeGOODS = System.currentTimeMillis();
            if(subs!=null&&subs.size()>0){

                Integer size = subs.size();
                if(pointsDataLimit<size){
                    int part = size/pointsDataLimit;//分批数
                    ExecutorService pool = Executors.newFixedThreadPool(part+1);

                    for (int c = 0; c < part; c++) {
                        List<GoodstrackedRecordTopPublicF6> listPage = subs.subList(0, pointsDataLimit);
                        try{
                            JSONArray a = (JSONArray) JSONObject.toJSON(listPage);
                            GoodsCallable callable = new GoodsCallable( "top",a.toString());
                            Future fContent = pool.submit(callable);
                        }catch (Exception e){
                            log.error("线程异常",e);

                        }
                        //剔除
                        subs.subList(0, pointsDataLimit).clear();
                    }
                    pool.shutdown();
                    if(!subs.isEmpty()){
                        try{
                            for (GoodstrackedRecordTopPublicF6 sub : subs) {
                                jrptExecutor.uploadGoodsTrace(SystemConstants.GOODS_URL,"",sub);
                            }
                        }catch (Exception e){
                            log.error("线程异常2",e);
                        }
                    }
                }else{
                    for (GoodstrackedRecordTopPublicF6 sub : subs) {
                        jrptExecutor.uploadGoodsTrace(SystemConstants.GOODS_URL,"",sub);
                    }
                }
            }
            afterGOODS = System.currentTimeMillis();
            System.out.println("补传订单信息用时：" + (afterGOODS - beforeGOODS) + "毫秒。");
        }catch (Exception e){
            //topService.selectNotList  subService.selNotUploadList
            log.info("补传订单信息异常 error:" ,e);
        }

        try {
            List<Jrpt> jrpts = jrptService.select();
            for (Jrpt jrpt : jrpts) {
                int num=0;
               try{
                   if(jrpt!=null&&jrpt.getOrganizationcode()!=null&&jrpt.getOrganizationcode().length()!=0){
                       String code=jrpt.getOrganizationcode();
                       Long beforeGOODS = System.currentTimeMillis();//货物跟踪推送开始时间
                       Long afterGOODS = System.currentTimeMillis();//货物跟踪推送结束时间
                       List<GoodsPublic> goods = subService.selectByNotUpload_List(code, begin, end);
                       Map<String, Object> ceshi = Maps.newHashMap();
                       ceshi.put("cccccc",goods);
                       List<GoodsPublic> ceshic =(List<GoodsPublic> )ceshi.get("cccccc");
                       num=goods.size();
                       beforeGOODS = System.currentTimeMillis();
                       if (goods!=null&& goods.size()>0){

                           Integer size = goods.size();
                           if(pointsDataLimit<size){

                               int part = size/pointsDataLimit;//分批数
                               ExecutorService pool = Executors.newFixedThreadPool(part+1);
                               for (int c = 0; c < part; c++) {

                                   List<GoodsPublic> listPage = goods.subList(0, pointsDataLimit);
                                   try{
                                       JSONArray a = (JSONArray) JSONObject.toJSON(listPage);
                                       GoodsCallable callable = new GoodsCallable( "1",a.toString());
                                       Future fContent = pool.submit(callable);
                                   }catch (Exception e){
                                       log.error("线程异常3",e);

                                   }
                                   //剔除
                                   goods.subList(0, pointsDataLimit).clear();
                               }
                               if(!goods.isEmpty()){
                                   try{
                                       JSONArray a = (JSONArray) JSONObject.toJSON(goods);
                                       GoodsCallable callable = new GoodsCallable( "1",a.toString());
                                       Future fContent = pool.submit(callable);
                                   }catch (Exception e){
                                       log.error("线程异常4",e);

                                   }
                               }
                               pool.shutdown();
                           }else{
                               try{

//                                   ExecutorService pool = Executors.newFixedThreadPool(1);
//                                   JSONArray a = (JSONArray) JSONObject.toJSON(goods);
//                                   GoodsCallable callable = new GoodsCallable( "1",a.toString());
//                                   Future fContent = pool.submit(callable);
//                                   pool.shutdown();
                         for (GoodsPublic good:goods){
                            jrptExecutor.uploadSubTracking(SystemConstants.GOODS_URL,good);
                         }
                               }catch (Exception e){
                                   log.error("线程异常4",e);

                               }

                           }
                       }
                       afterGOODS = System.currentTimeMillis();
                       System.out.println(code+"补传订单路由用时：" + (afterGOODS - beforeGOODS) + "毫秒。总数:"+num);
                   }
               } catch (Exception e){

               }
            }
        }catch (Exception e){
            log.info("补传路由信息异常 error:",e );
        }
        SimpleDateFormat sFormata = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String begina = sFormata.format(new Date());
        System.out.println("补传路由：完成 完成  完成"+begina);
    }

    @Override
    public void doUpload_Wx() {
        Long beforeSMS = System.currentTimeMillis();//微信推送开始时间
        Long afterSMS = System.currentTimeMillis();//微信推送结束时间
        SimpleDateFormat sFormat = new SimpleDateFormat("yyyy-MM-dd");
        String begin = sFormat.format(new Date())+" 00:00:00";
        String end   = sFormat.format(new Date())+" 23:59:59";

        try {
            List<Jrpt> jrpts = jrptService.wxIdselectList("");
            log.info("微信推送:Jrpt" + jrpts.size());
            for (Jrpt jrpt : jrpts) {
                if(jrpt!=null&&jrpt.getOrganizationcode()!=null&&jrpt.getOrganizationcode().length()!=0
                        &&jrpt.getWxid()!=null&&jrpt.getWxid().length()!=0){
                    List<GoodsPublic> goods = subService.selectWxNotUpload_List(jrpt.getOrganizationcode(), begin, end);
                    log.info("微信推送总数:" + goods.size());
                    if (goods!=null&& goods.size()>0){
                        for (GoodsPublic good:goods){
                            good.setWxpublicnumber(jrpt.getWxid());
                            jrptExecutor.doSendInfoWx(SystemConstants.WX_URL,good,jrpt);
                        }
                    }
                }

            }



        }catch (Exception e){
            log.info("微信推送总数异常 error:",e );
        }


    }

    @Override
    public void doUpload_Xcx() {
        Long beforeSMS = System.currentTimeMillis();//微信推送开始时间
        Long afterSMS = System.currentTimeMillis();//微信推送结束时间
        SimpleDateFormat sFormat = new SimpleDateFormat("yyyy-MM-dd");
        String begin = sFormat.format(new Date())+" 00:00:00";
        String end   = sFormat.format(new Date())+" 23:59:59";
        try {
            List<Jrpt> jrpts = jrptService.selectList("");
            for (Jrpt jrpt : jrpts) {
                if(jrpt!=null&&jrpt.getOrganizationcode()!=null&&jrpt.getOrganizationcode().length()!=0
                        &&jrpt.getAppid()!=null&&jrpt.getAppid().length()!=0){
                    List<GoodsPublic> goods = subService.selectXcxNotUpload_List(jrpt.getOrganizationcode(), begin, end);
                    log.info("小程序推送总数:" + goods.size());
                    if (goods!=null&& goods.size()>0){
                        for (GoodsPublic good:goods){
                            good.setXcxpublicnumber(jrpt.getAppid());
                            jrptExecutor.doSendInfoXcx(SystemConstants.XCX_URL,good,jrpt);
                        }
                    }
                }

            }



        }catch (Exception e){
            log.info("小程序推送总数异常 error:",e );
        }
    }
    static class GoodsCallable implements Callable<Object> {
//        private List<GoodsPublic> goods;
        private String type="";
        private String data="";

        GoodsCallable(String type,String data) {
            this.type = type;
            this.data=data;
        }

        public Object call() throws Exception {
            String result="";
            try{
                JSONArray json = JSONObject.parseArray(this.data);
                if("top".equals(this.type)){
                    List<GoodstrackedRecordTopPublicF6> subs= JSONArray.parseArray(json.toJSONString(),GoodstrackedRecordTopPublicF6.class);
                    if(subs!=null){
                        for (GoodstrackedRecordTopPublicF6 sub : subs) {
                            TraceUtil.doPostTop(sub);
                        }
                    }
                }else{
                    List<GoodsPublic> listPage = JSONArray.parseArray(json.toJSONString(),GoodsPublic.class);
                    if(listPage!=null){
                        for (GoodsPublic good:listPage){
                            TraceUtil.doPost(good);
                        }
                    }
                }

            }catch (Exception e){
                log.error("call error",e);
            }
            return result;
        }
    }


    @Override
    public void doUpload_Goods_Car(String beginDate,String endDate) {
        int pointsDataLimit = 300;//限制条数
        //查询未上传货物跟踪主
        SimpleDateFormat sFormat = new SimpleDateFormat("yyyy-MM-dd");
        String begin = sFormat.format(new Date())+" 00:00:00";
        String end   = sFormat.format(new Date())+" 23:59:59";
        if(beginDate!=null&&beginDate.length()!=0){
            begin = beginDate+" 00:00:00";
        }
        if (endDate!=null&&endDate.length()!=0){
            end   = endDate+" 23:59:59";
        }
        try{
            Long beforeGOODS = System.currentTimeMillis();
            Long afterGOODS = System.currentTimeMillis();

            List<TransportbillmasterPublic> subs =topService.selectCarNotUpload("", begin, end);
            log.info("派车总数:" + subs.size());
            beforeGOODS = System.currentTimeMillis();
            if(subs!=null&&subs.size()>0){
                for (TransportbillmasterPublic car : subs) {
                    jrptExecutor.uploadCar(SystemConstants.CAR_URL,car);
                }
            }
            afterGOODS = System.currentTimeMillis();
            System.out.println("上传派车信息用时：" + (afterGOODS - beforeGOODS) + "毫秒。");
        }catch (Exception e){
            //topService.selectNotList  subService.selNotUploadList
            log.info("上传派车信息异常 error:" ,e);
        }

    }
    @Override
    public void doUpload_CollectingMoney(String beginDate,String endDate) {
        int pointsDataLimit = 300;//限制条数
        //查询未上传货物跟踪主
        SimpleDateFormat sFormat = new SimpleDateFormat("yyyy-MM-dd");
        String begin = sFormat.format(new Date())+" 00:00:00";
        String end   = sFormat.format(new Date())+" 23:59:59";
        if(beginDate!=null&&beginDate.length()!=0){
            begin = beginDate+" 00:00:00";
        }
        if (endDate!=null&&endDate.length()!=0){
            end   = endDate+" 23:59:59";
        }
        try{
            Long beforeGOODS = System.currentTimeMillis();
            Long afterGOODS = System.currentTimeMillis();

            List<CollectiongoodsvalueaccountPublic> subs =topService.selectCollectionMoneyNotUpload("", begin, end);
            log.info("代收总数:" + subs.size());
            beforeGOODS = System.currentTimeMillis();
            if(subs!=null&&subs.size()>0){
                for (CollectiongoodsvalueaccountPublic car : subs) {
                    jrptExecutor.uploadCollection(SystemConstants.CAR_URL,car);
                }
            }
            afterGOODS = System.currentTimeMillis();
            System.out.println("上传代收信息用时：" + (afterGOODS - beforeGOODS) + "毫秒。");
        }catch (Exception e){
            //topService.selectNotList  subService.selNotUploadList
            log.info("上传代收信息异常 error:" ,e);
        }

    }

    @Override
    public void doUpload_Goods_CarBc(String beginDate,String endDate) {
        int pointsDataLimit = 300;//限制条数
        //查询未上传货物跟踪主
        SimpleDateFormat sFormat = new SimpleDateFormat("yyyy-MM-dd");
        String begin = sFormat.format(new Date())+" 00:00:00";
        String end   = sFormat.format(new Date())+" 23:59:59";
        if(beginDate!=null&&beginDate.length()!=0){
            begin = beginDate+" 00:00:00";
        }
        if (endDate!=null&&endDate.length()!=0){
            end   = endDate+" 23:59:59";
        }
        int zs=9000;
        for(int i=1;i<zs;i++)
        {
            try{
                Long beforeGOODS = System.currentTimeMillis();
                Long afterGOODS = System.currentTimeMillis();
                List<TransportbillmasterPublic> subs =topService.selectCarNotUploadBC("", begin, end,(i*zs));
                if(subs==null||subs.size()==0){
                    break;
                }
                log.info("派车总数:" + subs.size());
                beforeGOODS = System.currentTimeMillis();
                if(subs!=null&&subs.size()>0){
                    for (TransportbillmasterPublic car : subs) {
                        jrptExecutor.uploadCar(SystemConstants.CAR_URL,car);
                    }
                }
                afterGOODS = System.currentTimeMillis();
                System.out.println("i:"+i+"补传派车信息用时：" + (afterGOODS - beforeGOODS) + "毫秒。");
            }catch (Exception e){
                //topService.selectNotList  subService.selNotUploadList
                log.info("补传派车信息异常 error:" ,e);
            }
        }
        System.out.println("补传派车完成 完成 完成 begin:"+begin+" end:"+end);
    }
    @Override
    public void doUpload_CollectingMoneyBC(String beginDate,String endDate) {
        int pointsDataLimit = 300;//限制条数
        //查询未上传货物跟踪主
        SimpleDateFormat sFormat = new SimpleDateFormat("yyyy-MM-dd");
        String begin = sFormat.format(new Date())+" 00:00:00";
        String end   = sFormat.format(new Date())+" 23:59:59";
        if(beginDate!=null&&beginDate.length()!=0){
            begin = beginDate+" 00:00:00";
        }
        if (endDate!=null&&endDate.length()!=0){
            end   = endDate+" 23:59:59";
        }
        int num=9000;
        for(int i=1; i<num;i++){
            try{
                Long beforeGOODS = System.currentTimeMillis();
                Long afterGOODS = System.currentTimeMillis();
                List<CollectiongoodsvalueaccountPublic> subs =topService.selectCollectionMoneyNotUploadBC("", begin, end,num);
                if(subs==null||subs.size()==0){
                    break;
                }
                log.info("补传总数:" + subs.size());
                beforeGOODS = System.currentTimeMillis();
                if(subs!=null&&subs.size()>0){
                    for (CollectiongoodsvalueaccountPublic car : subs) {
                        jrptExecutor.uploadCollection(SystemConstants.CAR_URL,car);
                    }
                }
                afterGOODS = System.currentTimeMillis();
                System.out.println("补传代收信息用时：" + (afterGOODS - beforeGOODS) + "毫秒。");
            }catch (Exception e){
                //topService.selectNotList  subService.selNotUploadList
                log.info("补传代收信息异常 error:" ,e);
            }
        }
        System.out.println("补传代收完成 完成 完成 begin:"+begin+" end:"+end);

    }
}
